#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
//http://www.oj7.cn/
int arr[10009];
int n;
int ans;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> arr[i]
			;
	}
	int t;
	int k = 0;
	for (int i = 0; i < n; i++)
	{
		t = arr[k];
		if (arr[i] < t)
		{
			ans++;
		}
		if (i == n - 1)
		{
			i =k;
			k++;
			if (k == n)
			{
				cout << ans << endl;
				return 0;
			}
		}
	
	}
	cout << ans << endl;
	return 0;
}